package com.missyoubug.easyjtest.util;


public class Messages {

    private Messages() {

    }

    public static <D> Message<D> success(D data) {
        return new Message(Result.SUCCESS, Code.SUCCESS.getValue(), data);
    }

    public static <D> Message<D> success() {
        return (Message<D>) success((Object) null);
    }

    public static <D> Message<D> failed(int code) {
        return new Message<>(Result.FAILED, code);
    }

    public static <D> Message<D> failed(Integer code, String msg) {
        return new Message(Result.FAILED, code, msg);
    }

    public static <D> Message<D> error() {
        return new Message(Result.ERROP, (Object) null);
    }

    public static <D> Message<D> error(int code) {
        return new Message(Result.ERROP, code);
    }

    public static boolean isSuccess(Message<?> message) {
        return Result.SUCCESS.equals(message.getResult());
    }
}
